package cn.xy.third.alipay.service;

import cn.xy.third.alipay.bean.AlipayConfig;
import com.alipay.api.AlipayClient;
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
import com.alipay.easysdk.kernel.Config;
import com.alipay.easysdk.payment.common.models.AlipayTradeRefundResponse;

import java.math.BigDecimal;
import java.util.Map;

/**
 * 支付宝支付相关服务
 *
 *  @author xy
 */
public interface AlipayService {

    /**
     * setOptions
     *
     * @param alipayConfig alipayConfig
     */
    void setOptions(AlipayConfig alipayConfig);

    /**
     * getOptions
     *
     * @param alipayConfig alipayConfig
     * @return Config
     */
    Config getOptions(AlipayConfig alipayConfig);

    /**
     * 手机网站支付
     *
     * @param subject    subject
     * @param outTradeNo outTradeNo
     * @param amount     amount
     * @param quitUrl    quitUrl
     * @param returnUrl  returnUrl
     * @return result
     */
    String wapUnifiedOrder(String subject, String outTradeNo, BigDecimal amount, String quitUrl, String returnUrl);

    /**
     * pc网站支付
     *
     * @param subject    subject
     * @param outTradeNo outTradeNo
     * @param amount     amount
     * @param returnUrl  returnUrl
     * @return result
     */
    String webUnifiedOrder(String subject, String outTradeNo, BigDecimal amount, String returnUrl);

    /**
     * 申请退款
     *
     * @param payTradeNo payTradeNo
     * @param payTotal   payTotal
     * @return result
     */
    AlipayTradeRefundResponse refund(String payTradeNo, BigDecimal payTotal);

    /**
     * notifyVerified
     *
     * @param payNotifyMap payNotifyMap
     * @return result
     */
    Boolean notifyVerified(Map<String, String> payNotifyMap);

    /**
     * appPay
     *
     * @param subject    subject
     * @param outTradeNo outTradeNo
     * @param amount     amount
     * @return result
     */
    String appPay(String subject, String outTradeNo, BigDecimal amount);

    /**
     * 转账到支付宝账户
     *
     * @param alipayConfig 支付宝配置
     * @param amount       转账数额
     * @param withdrawNo   系统转账单号
     * @param name         收款人真实姓名
     * @param account      收款账户
     * @param companyName  公司名
     * @param desc         备注
     * @return 转账结果
     */
    AlipayFundTransUniTransferResponse getAccountRequestData(AlipayConfig alipayConfig, BigDecimal amount, String withdrawNo, String name, String account, String companyName, String desc);

    /**
     * 转账到支付宝账户-请求参数
     *
     * @param amount      转账数额
     * @param withdrawNo  系统转账单号
     * @param name        收款人真实姓名
     * @param account     收款账户
     * @param companyName 公司名
     * @param desc        备注
     * @return 转账结果
     */
    String getAlipayFundTransUniTransferRequestContent(BigDecimal amount, String withdrawNo, String name, String account, String companyName, String desc);

    /**
     * 公钥证书方式
     *
     * @param alipayConfig 支付宝配置
     * @return 签名参数
     */
    AlipayClient getCertAlipayClient(AlipayConfig alipayConfig);
}
